﻿using System;

namespace Program25
{
    class Program
    {
        static void Main(string[] args)
        {
            //GetSum(1,4,5,7...)求任意长度的和
            Console.WriteLine( GetSum(8, 9,10));
            Console.WriteLine(GetSum(5, 9, 10));
            //GetSum("张三",学号,成绩1,成绩2)求任意门课程的总分
            //Test("张三", 123456789, 12, 23);
            GetScoer("龙哥", 123456, 45, 60, 90);
        }
        //params 定义可变参数
        public static int GetSum(params int[] n)
        {
            var sum = 0;
            for(var i = 0; i < n.Length; i++)
            {
                sum += n[i];
            }
            return sum;
        }
        public static void Test(params Object[] objs)
        {
            Console.WriteLine(objs[0]);
            Console.WriteLine(objs[1]);
            Console.WriteLine(objs[2]);
            Console.WriteLine(objs[3]);
        }
        public static void GetScoer(string name,int id,params int[] scores)
        {
            Console.WriteLine("学号:" + id);
            Console.WriteLine("姓名:" + name);
            var sum = 0;
            for(var i = 0; i < scores.Length; i++)
            {
                sum += scores[i];
            }
            Console.WriteLine("总分:" + sum);
            Console.WriteLine("平均分:" + sum / scores.Length);
        }
    }
}
